%%%-------------------------------------------------------------------
%%% File        : mailers.erl
%%% Author      : Fyodor Ustinov <ufm@ufm.su>
%%% Description : MailEr project
%%%               Main supervisor module
%%%
%%% Created : 31 Aug 2009 by Fyodor Ustinov <ufm@ufm.su>
%%%-------------------------------------------------------------------
-module(mailers).

-behaviour(supervisor).

%% API
-export([start_link/0,start/0]).

%% Supervisor callbacks
-export([init/1]).

-define(SERVER, ?MODULE).

%%====================================================================
%% API functions
%%====================================================================
%%--------------------------------------------------------------------
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
%% Description: Starts the supervisor
%%--------------------------------------------------------------------
start() ->
    {ok, Pid} = supervisor:start_link({local, ?SERVER}, ?MODULE, []),
    unlink(Pid).

start_link() ->
    supervisor:start_link({local, ?SERVER}, ?MODULE, []).

%%====================================================================
%% Supervisor callbacks
%%====================================================================
%%--------------------------------------------------------------------
%% Func: init(Args) -> {ok,  {SupFlags,  [ChildSpec]}} |
%%                     ignore                          |
%%                     {error, Reason}
%% Description: Whenever a supervisor is started using 
%% supervisor:start_link/[2,3], this function is called by the new process 
%% to find out about restart strategy, maximum restart frequency and child 
%% specifications.
%%--------------------------------------------------------------------
init([]) ->
    Childs = [
	      {'storage', {'storage', start_link, []}, transient, 20000, worker, ['storage']},
	      {'start_storage', {'storage', start_storage, []}, temporary, 60000, worker, ['storage']},
	      {'config', {'config', start_link, []}, transient, 20000, worker, ['config']},
	      {'smtpd',{'smtpd',start_link,[]},transient,20000,worker,['smtpd', 'smtpdc']},
	      {'filter',{'filter',start_link,[]},transient,20000,worker,['filter']}
	     ],
    {ok,{{one_for_one,1,1}, Childs}}.

%%====================================================================
%% Internal functions
%%====================================================================
